package Math;

import java.util.Scanner;

public class 自幂数 {
    public static void main(String[] args) {
        long star = System.currentTimeMillis();
        System.out.println(panduan_zimishu(100, 999,length(999)));
        long end = System.currentTimeMillis();
        System.out.println((end-star));
    }
    public static int length(int y) {
        int length = 0;
        while (y != 0) {
            y = y / 10;
            length++;
        }
        return length;
    }

    public static int panduan_zimishu(int x, int y,int length) {
        int count = 0;
        for (int i = x; i <= y; i++) {
            double sum = 0;
            for (int j = 0; j < length; j++) {
                int ge = (int) (i / Math.pow(10, j) % 10);
                sum += Math.pow(ge, length);
            }
            if (sum == i) {
                System.out.println(sum);
                count++;
            }
        }
        return count;
    }
}